#include "swpsimmergegraphicitem.h"

#include "graphicitemcommon.h"

using namespace core;
using namespace swp;

SwpSimMergeGraphicItem::SwpSimMergeGraphicItem(QGraphicsItem* parent) :
    SwpMergeGraphicItem(parent), ISimItem(),
        m_isInSimPath(false),
        m_originId()
{
    setFlag(QGraphicsItem::ItemIsMovable, false);
}

SwpSimMergeGraphicItem::SwpSimMergeGraphicItem(
    SwpMergeGraphicItem* from,
        QGraphicsItem* parent) : SwpMergeGraphicItem(parent), ISimItem(),
        m_isInSimPath(false),
        m_originId(from->id())
{
    setFlag(QGraphicsItem::ItemIsMovable, false);

    setPos(from->pos());
}

SwpSimMergeGraphicItem::~SwpSimMergeGraphicItem()
{

}

bool SwpSimMergeGraphicItem::supportsConnection(
        const ConnectionData& connection) const
{
    return connection.ConnectionId == CONNECTION_SIM_PATH;
}

int SwpSimMergeGraphicItem::type() const
{
    return SWP_SIM_MERGE_ITEM;
}

IEditorItem* SwpSimMergeGraphicItem::copy() const
{
    return new SwpSimMergeGraphicItem();
}

bool SwpSimMergeGraphicItem::isInSimPath() const
{
    return m_isInSimPath;
}

void SwpSimMergeGraphicItem::setInSimPath(bool in)
{
    if (in)
    {
        setPen(QPen(m_palette->acceptsConnectionColor(), 2));
    }
    else
    {
        setPen(QPen(m_palette->borderColor(), 1));
    }

    m_isInSimPath = in;
}

QUuid SwpSimMergeGraphicItem::originId() const
{
    return m_originId;
}
